package org.lee.http;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.time.LocalDateTime;

/**
 * DateServer
 * 日期服务器
 *
 * @author dralee
 * @date 2021-12-28 17:14:49
 **/
public class DateServer {

    public static void main(String[] args) throws IOException {
        int port = 12345;
        try (ServerSocket listener = new ServerSocket(port)) {
            System.out.printf("The started on port %d%n", port);
            while (true) {
                try (Socket socket = listener.accept()) {
                    try (PrintWriter writer = new PrintWriter(socket.getOutputStream(), true)) {
                        writer.println(LocalDateTime.now());
                    }
                }

            }
        }
    }
}